package com.gxuwz.dsj.Controller;


import com.gxuwz.dsj.Bean.Admin;
import com.gxuwz.dsj.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller
public class AdminController {

    @Autowired
    private AdminService adminService;


    @RequestMapping("/login")
    public Admin loginReq(String userName, String password, String code, HttpServletRequest request){

        Admin login = adminService.login(userName, password);

        Object captcha = request.getSession().getAttribute("captcha");

        if (captcha.equals(code)){
            if (login!=null){
                return login;

            }
        }

        return null;
    }
}
